package com.project.user.serviet;

import com.alibaba.fastjson.JSON;
import com.untils.Resultant;
import com.untils.ResultantUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "UserLoginServlet", value = "/user-login")
public class UserLoginServlet extends HttpServlet {


    @Override
    public void init() throws ServletException {
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultantUtil resultantUtil = new ResultantUtil();
        String username = req.getParameter("user-name");
        String password = req.getParameter("user-password");

        resp.setContentType("application/json");
        resp.setCharacterEncoding("UTF-8");
        PrintWriter out = resp.getWriter();
        Resultant response = resultantUtil.getFreeResult(HttpServletResponse.SC_OK, "successfully", null);
        out.write(JSON.toJSONString(response));
        out.close();
    }

    @Override
    public void destroy() {
    }
}
